import { defineComponent, onMounted, ref } from 'vue'
import './index.less'
import {
  Button,
  Space,
  Form,
  RangePicker,
  Select,
  Avatar,
} from 'ant-design-vue'
import TooltipCom from '@/components/tooltipCom'
import TableCom from '@/components/tableCom'
import { PaginationType } from '@/components/tableCom/type'
export default defineComponent({
  name: 'Home',
  setup() {
    const columns = [
      {
        title: '订单类型',
        dataIndex: 'scType',
        ellipsis: true,
      },
      {
        title: '是否提交微信',
        dataIndex: 'isSubmitQw',
        ellipsis: true,
        customRender: ({ text }: any) => {
          return text == '1' ? (
            <span style={{ color: '#1890ff' }}>已提交</span>
          ) : (
            <span>未提交</span>
          )
        },
      },
      {
        title: '合同状态',
        dataIndex: 'scStatus',
        ellipsis: true,
        customRender: ({ text }: any) => {
          return <TooltipCom text={text}></TooltipCom>
        },
      },
      {
        title: '最新流程状态',
        dataIndex: 'scFlowStatus',
        ellipsis: true,
      },
      {
        title: '合同编号',
        dataIndex: 'scContractCode',
        customRender: ({ text }: any) => {
          return <TooltipCom text={text}></TooltipCom>
        },
      },
      {
        title: '甲方',
        dataIndex: 'partyA',
        ellipsis: true,
        customRender: ({ text }: any) => {
          return <TooltipCom text={text}></TooltipCom>
        },
      },
      {
        title: '乙方',
        dataIndex: 'partyB',
        ellipsis: true,
      },
      {
        title: '签订日期',
        dataIndex: 'signingDate',
        ellipsis: true,
        customRender: ({ text }: any) => {
          return <TooltipCom text={text}></TooltipCom>
        },
      },
      {
        title: '签订金额(元)',
        dataIndex: 'signingPrice',
        ellipsis: true,
      },
      // {
      //   title: '含税金额',
      //   dataIndex: 'updater',
      // },
      // {
      //   title: '商品数量',
      //   dataIndex: 'updater',
      // },
      {
        title: '创建人',
        dataIndex: 'createTime',
      },
      {
        title: '创建日期',
        dataIndex: 'createTime',
        ellipsis: true,
        customRender: ({ text }: any) => {
          return <TooltipCom text={text}></TooltipCom>
        },
      },
      {
        title: '操作',
        dataIndex: 'operational',
        fixed: 'right',
        customRender: ({ text, record }: any) => (
          <Space>
            <Button type="link" size="small">
              详情
            </Button>
            <Button type="link" size="small">
              编辑
            </Button>
          </Space>
        ),
      },
    ]
    const dataSource = ref<any[]>([])
    const selectedRowKeys = ref<Array<number | string>>([])
    const pagination = ref<PaginationType>({
      current: 1,
      pageSize: 10,
      total: 0,
    })
    const handleTableChange = (e: any) => {
      pagination.value.current = e.current
      pagination.value.pageSize = e.pageSize
      //   getData()
    }
    onMounted(() => {
      setTimeout(() => {
        dataSource.value = [
          {
            scId: '160548706b5211ef9e6f02cbd375f796',
            scType: '1',
            internalPcId: null,
            externalPcId: null,
            saleUser: '1',
            certUser: '1',
            outUsers: '1,3,4',
            customId: '23',
            saleCommission: '20.00',
            orderLeaderUserId: '1',
            outUserCost: '47.1',
            scContractCode: '123456789007',
            scContractName: '美国正货',
            partyA: '迪科产业公司',
            partyB: '红川物流',
            partyALeader: '老七',
            partyBLeader: '老六',
            signingDate: '2024-09-05',
            signingPrice: '4567.00',
            taxRate: '12.70',
            paymentMethod: '0',
            paymentPrice: '345.00',
            paymentTime: '2024-08-30 12:34:23',
            isAdvanceTax: '0',
            isSubmitQw: '1',
            scFlowStatus: '0',
            scStatus: '1',
            creator: '1',
            createTime: '2024-09-05 14:42:57',
          },
          {
            scId: '56200a706a9011ef806d0242fb9d33fb',
            scType: '1',
            internalPcId: null,
            externalPcId: null,
            saleUser: '俄国',
            certUser: '对付敌人',
            outUsers: '大饭店',
            customId: '大哥',
            saleCommission: '10.00',
            orderLeaderUserId: '戴菲菲',
            outUserCost: '23',
            scContractCode: '3486786549',
            scContractName: '白板合同',
            partyA: '大声告诉我',
            partyB: '蠢才方改了',
            partyALeader: '防抖',
            partyBLeader: '返回',
            signingDate: '2024-09-04',
            signingPrice: '120.00',
            taxRate: '12.00',
            paymentMethod: '1',
            paymentPrice: '23.00',
            paymentTime: '2024-09-04',
            isAdvanceTax: '0',
            isSubmitQw: '1',
            scFlowStatus: '0',
            scStatus: '1',
            creator: '1',
            createTime: '2024-09-04 15:36:02',
          },
        ]
      }, 500)
    })
    return () => {
      return (
        <div class="home-box">
          <TableCom
            columns={columns}
            dataSource={dataSource.value}
            rowSelection
            handleTableChange={handleTableChange}
            pagination={pagination.value}
            v-model={[selectedRowKeys.value, 'selectedRowKeys']}
            scroll={{ x: true }}
          ></TableCom>
        </div>
      )
    }
  },
})
